<?php

$h = $_ENV["HTTP_HOST"];
$q = $_ENV["REQUEST_URI"];

if(!ereg("^www\.", $h) && !ereg("\.[0-9]+$", $h)){
    header("Location: http://www.".$h.$q);
    exit;
}
                // ^[/]?
$q = ereg_replace("/([^\?]*)[\?]?(.*)$", "\\1", $q);
if(strtolower($q) == "index.php"){
    header("Location: /");
    exit;
}

require_once "../conf/config.php";

try {
    require '../conf/bootstrap.php';
} catch (Exception $exception) {
    echo '<html><body><center>'
       . 'An exception occured while bootstrapping the application.';
    if (defined('APPLICATION_ENVIRONMENT')
        && APPLICATION_ENVIRONMENT != 'production'
    ) {
        echo '<br /><br />' . $exception->getMessage() . '<br />'
           . '<div align="left">Stack Trace:' 
           . '<pre>' . $exception->getTraceAsString() . '</pre></div>';
    }
    echo '</center></body></html>';
    exit(1);
}
                                             
Zend_Controller_Front::getInstance()->dispatch();
